from django.utils.deprecation import MiddlewareMixin
# MiddlewareMixin
class TestMiddleware(MiddlewareMixin):

    def process_request(self,request):
        print('request 每次请求前 都会调用')
#在每次响应前 都会调用
        # user=request.COOKIES.get('user')
        # if user is not None:
        #     print('请登录')
        # else:
        #     print('费登录')

    def process_response(self,request,response):
        print('response 每次响应前 都会调用')
# 记得 响应要返回
        return response
class TestMiddleware1(MiddlewareMixin):

    def process_request(self,request):
        print('11111111111111request')
#在每次响应前 都会调用
        # user=request.COOKIES.get('user')
        # if user is not None:
        #     print('请登录')
        # else:
        #     print('费登录')

    def process_response(self,request,response):
        print('111111111111response ')
# 记得 响应要返回
        return response
